package com.bosssoft.goods.domain.dto;

import com.bosssoft.goods.domain.bean.Category;
import com.bosssoft.goods.domain.bean.GoodsImageInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

/**
 * 商品查询返回对象
 * @author Fang_Sir
 * @date 2021-04-20
 */
@Getter
@Setter
public class GoodSearchDTO {
    private long id;
    private String name;
    private int brandId;
    private String brandName;
    private int[] catArr;
    private Category[] catDetail;
    /**
     * 商品分类品牌关联编号
     */
    private int catBrand;
    private int stock;
    private double price;
    private boolean onSale;
    private boolean isDeleted;
    private String content;
    private GoodsImageInfo[] imgs;
    private String[] imgUrls;


    public int[] getCatArr(){
        int[] catArr = new int[3];
        catArr[0] = catRoot;
        catArr[1] = catFun;
        catArr[2] = catType;
        return catArr;
    }

    public Category[] getCatDetail() {
        Category[] catArray = new Category[3];
        catArray[0] = root;
        catArray[1] = fun;
        catArray[2] = type;
        return catArray;
    }

    public String[] getImgUrls() {
        String[] urls = new String[imgs.length];
        for (int i = 0; i < imgs.length; i++){
            urls[i] = imgs[i].getUrl();
        }
        return urls;
    }

    /**
     * 一级分类
     */
    @JsonIgnore
    private int catRoot;
    @JsonIgnore
    private Category root;
    /**
     * 二级分类
     */
    @JsonIgnore
    private int catFun;
    @JsonIgnore
    private Category fun;
    /**
     * 三级分类
     */
    @JsonIgnore
    private int catType;
    @JsonIgnore
    private Category type;
}
